//
//  ThemeLabel.m
//  Weibo
//
//  Created by taoshanchang on 15/1/26.
//  Copyright (c) 2015年 taoshanchang. All rights reserved.
//

#import "ThemeLabel.h"
#import "ThemeManager.h"

@implementation ThemeLabel

- (id)init
{
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeNotification:) name:kThemeDidChangeNotification object:nil];
    }
    return self;
}

-(ThemeLabel *)initWithColorName:(NSString *)colorName{
    self = [self init];
    if (self) {
        self.colorName = colorName;
    }
    return self;
}

-(void)setColorName:(NSString *)colorName{
    if(_colorName != colorName ){
        _colorName = colorName;
    }
    [self setColor];
}

-(void)setColor{
    UIColor *textColor = [[ThemeManager sharedInstance] getColorWithName:_colorName];
    self.textColor = textColor;
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:kThemeDidChangeNotification object:nil];
}

-(void)themeNotification:(NSNotification *)notification{
    [self setColor];
}

@end
